﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

namespace Yoozoo.Gta.Modules.Debugger
{
    public class GuiComponent : MonoBehaviour
    {
        public string LuaFunctionName;

        private string oldLuaFunctionName;

        private XLua.LuaFunction luaFunction;

        public void OnGUI()
        {
            if (oldLuaFunctionName != LuaFunctionName)
            {
                oldLuaFunctionName = LuaFunctionName;
                luaFunction = null;
            }
            
            if (string.IsNullOrEmpty(LuaFunctionName))
            {
                return;
            }
            
            if (luaFunction == null)
            {
                luaFunction = Yoozoo.Framework.Managers.LuaManager.mainState.Global.GetInPath<XLua.LuaFunction>(LuaFunctionName);
            }

            if (luaFunction == null)
            {
                return;
            }
            
            luaFunction.Call();
            
        }
    }
}

